package com.gxar.quick.ar.server.base.controller;

import com.gxar.common.entity.Result;
import com.gxar.common.entity.SlippageResult;
import com.gxar.common.entity.login.LoginUserThread;
import com.gxar.common.entity.login.UserProfile;
import com.gxar.quick.ar.server.base.model.order.vo.response.OrderListResponse;
import com.gxar.quick.ar.server.db.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单接口
 *
 * @author linsy
 * @version 1.0
 * @created 2023/11/3 15:44
 */
@Api(tags = "订单接口")
@RestController
@RequestMapping("/api/orders")
@RequiredArgsConstructor
@Slf4j
public class OrderController {

    private final OrderService orderService;

    @ApiOperation("订单列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "next_id", value = "下一个查询的id", dataType = "string"),
    })
    @GetMapping("")
    public Result<SlippageResult<OrderListResponse>> list(@RequestParam(name = "next_id", required = false) String nextId) {
        UserProfile userProfile = LoginUserThread.get();
        SlippageResult<OrderListResponse> response = orderService.list(userProfile, nextId);
        return Result.success(response);
    }

}
